/* 
 * Author: anand
 * 
 */


#ifndef _DBHELPER_H
#define	_DBHELPER_H

#include "lib/sqlite3.h"
#include "consts.h"
#include "path_util.h"
#include <vector>
#include <map>
#include <string>

class table{
    char *_name;
    char *_creationSQL;
public:
    table(char *name_,char* creationSQL_){
        _name = name_;
        _creationSQL = creationSQL_;
    }

    char * creation_sql(){return _creationSQL;}
    char *name(){return _name;}
};

typedef const std::vector< std::map<std::string,std::string> * >  result_set;

class dbhelper {
public:
    void connect(char *  dbName);
    int raw_execute(const char * sql);
    bool table_exists(table *table_);
    void table_create(table *table_);
    static dbhelper * get_helper();
    result_set * get_row_map(const char *sql);
    virtual ~dbhelper();
	int get_id(const char * table_name);
private:
    sqlite3 *_db;
    void init_db();
    dbhelper();
    dbhelper(const dbhelper& orig);
    /*TABLES*/
    table *playlist_table;
    table *folder_table;
    table *playlistitem_table;
    table *playlistitems_table;
};


#endif	/* _DBHELPER_H */

